package com.todo.strategy.online.application.frontend.controller;

import com.todo.common.common.entity.response.BizResponse;
import com.todo.strategy.online.application.frontend.service.MemoUserRelationAggService;
import com.todo.strategy.online.iface.MemoUserRelationFrontendIface;
import com.todo.strategy.online.iface.request.*;
import com.todo.strategy.online.iface.response.MemoUserRelationDetailVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/11/29 19:08
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/strategy/memo")
@Tag(name = "备忘录用户关联前台接口", description = "备忘录用户关联前台接口")
public class MemoUserRelationFrontendController implements MemoUserRelationFrontendIface {

    @Resource
    private MemoUserRelationAggService memoUserRelationAggService;

    @Override
    @Operation(summary = "拷贝构建备忘录关联")
    @PostMapping("/buildMemoUserRelationByTemplate")
    public BizResponse<Boolean> buildMemoUserRelationByTemplate(@RequestBody BuildMemoUserRelationByTemplateParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return memoUserRelationAggService.buildMemoUserRelationByTemplate(param);
    }

    @Override
    @Operation(summary = "根据主键更新备忘录关联")
    @PostMapping("/updateMemoUserRelationById")
    public BizResponse<Boolean> updateMemoUserRelationById(@RequestBody UpdateMemoUserRelationByIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return memoUserRelationAggService.updateMemoUserRelationById(param);
    }

    @Override
    @Operation(summary = "根据主键删除备忘录关联")
    @PostMapping("/removeMemoUserRelationById")
    public BizResponse<Boolean> removeMemoUserRelationById(@RequestBody RemoveMemoUserRelationByIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return memoUserRelationAggService.removeMemoUserRelationById(param);
    }

    @Override
    @Operation(summary = "根据计划Id查询备忘录关联")
    @PostMapping("/queryMemoUserRelationListByPlanId")
    public BizResponse<MemoUserRelationDetailVO> queryMemoUserRelationListByPlanId(@RequestBody QueryMemoUserRelationListByPlanIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return memoUserRelationAggService.queryMemoUserRelationListByPlanId(param);
    }

    @Override
    @Operation(summary = "根据主键查询备忘录关联")
    @PostMapping("/queryMemoUserRelationById")
    public BizResponse<MemoUserRelationDetailVO> queryMemoUserRelationById(@RequestBody QueryMemoUserRelationByIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return memoUserRelationAggService.queryMemoUserRelationById(param);
    }
}
